package top.kaoshanji.p2ch10b;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import top.kaoshanji.u1constant.FileConstant;

import java.io.IOException;

/**
 * 代码清单-p2ch10a-01：对象替换示例
 * author kaoshanji
 * ^_^
 * create time 2025/2/3 11:42
 */
public class OrderTest {

    private static final Logger logger = LogManager.getLogger(OrderTest.class);

    public static void main(String[] args) throws IOException, ClassNotFoundException {
        logger.info("...代码清单-p2ch10a-01：对象替换示例...");

        User user = new User("Bob", "bob@example.org");
        Order order = new Order("1", user);

        String path = FileConstant.LOCAL_ROOT_PATH.concat("p2ch10b329页a\\order.bin");

        SerializationUtils.write(order, path);

        order = (Order)SerializationUtils.read(path);

        logger.info("...订单的Id的值：{}...", order.getId());

    }

}
